#以下四个乘法表为for..in循环九九乘法表
#左下三角九九乘法表

for a in range(1,10):
    for b in range(1,a+1):
        print("{}*{}={:<4}".format(b,a,a*b),end=" ")
    print("")
print("")
print("="*26,"for循环左下三角九九乘法表","="*26)
print("")
#左上三角九九乘法表
for a in range(1,10):
    for b in range(a,10):
        print("{}*{}={:<4}".format(a,b,a*b),end="")
    print("")

print("")
print("="*26,"for循环左上三角九九乘法表","="*26)
print("")

#右下三角九九乘法表
for a in range(1,10):
    for b in range(1,10-a):
        print(end="        ")
    for c in range(1,a+1):
        print("{}*{}={:<4}".format(a,c,a*c),end="")
    print("")

print("")
print("="*26,"for循环右下三角九九乘法表","="*26)
print("")

#右上三角九九乘法表
for a in range(1,10):
    for c in range(1,a):
        print(end="        ")
    for b in range(a,10):
        print("{}*{}={:<4}".format(a,b,a*b),end="")
    print("")

print("")
print("="*26,"for循环右上三角九九乘法表","="*26)
print("")

#以下四个乘法表为while循环九九乘法表

#左下三角九九乘法表
i=1
while i<=9:
    j=1
    while j<=i:
        print("{}*{}={:<4}".format(j,i,i*j), end=" ")
        j+=1
    print("")
    i=i+1

print("")
print("="*25,"while循环左下三角九九乘法表","="*25)
print("")


#左上三角九九乘法表
i=9
while i>0:
    j=1
    while j<=i:
        print("{}*{}={:<4}".format(j,i,i*j), end="")
        j+=1
    print("")
    i=i-1

print("")
print("="*25,"while循环左上三角九九乘法表","="*25)
print("")

#右下三角九九乘法表
i=1
while i<=9:
    j=1
    while j<=9-i:
        print("        ",end="")
        j+=1
    k=1
    while k<=i:
        print("{}*{}={:<4}".format(k,i,i*k), end="")
        k+=1
    print("")
    i=i+1

print("")
print("="*25,"while循环右下三角九九乘法表","="*25)
print("")


#右上三角九九乘法表
i=9
while i>0:
    j=1
    while j<=9-i:
        print("        ",end="")
        j+=1
    k=1
    while k<=i:
        print("{}*{}={:<4}".format(k,i,i*k), end="")
        k+=1
    print("")
    i=i-1

print("")
print("="*25,"while循环右上三角九九乘法表","="*25)
print("")
